﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
using System.Text;
using Gueei.Gallery.Core.Entities;

namespace Gueei.Gallery.Web.ViewModels
{
	public class ImageViewModel
	{
		[Required]
		public string Name { get; set; }

		public Guid Id { get; set; }

		public string Description { get; set; }

		public DateTime CreateDate { get; set; }
		public string OriginalFileName { get; set; }
		public DateTime LastModified { get; set; }
		public virtual string[] Tags { get; set; }

		public static ImageViewModel CreateFromImage(Image image)
		{
			return image == null ? 
				null:
				new ImageViewModel
			       	{
			       		Name = image.Name,
			       		Id = image.Id,
			       		Description = image.Description,
			       		Tags = image.Tags.Select(t => t.Name).ToArray(),
			       		CreateDate = image.CreateDate,
			       		OriginalFileName = image.OriginalFileName,
						LastModified = image.LastModified
			       	};
		}

		public string Set { get; set; }
		public int Position { get; set; }
	}
}
